home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
asm_n_z.zip
/
NEWXDIR.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-04-07
|
43KB
|
841 lines
;XDIR.COM for the IBM Personal Computer - 1986 by Jeff Prosise
code segment para public 'code'
assume cs:code
org 100h
begin: jmp initialize ;goto initialization code
;
copyright db 'Copyright 1986 Ziff-Davis Publishing Co.',1Ah
global db '\*.*',0 ;global directory filespec
dos_segment dw ? ;DOS segment
busy_flag dw ? ;offset of DOS BUSY_FLAG
program_status db 0 ;XDIR processing status
flag_13h db 0 ;status of interrupt 13h
request_flag db 0 ;status of processing request
adapter db 2 ;0 = MDA, 1 = CGA, 2 = EGA
video_segment dw 0B800h ;video segment address
video_page db ? ;current video page
border_attr db 4Fh ;window border attribute
text_attr db 0Fh ;window text attribute
video_address dw ? ;window start address
cursor_mode dw ? ;cursor shape
cursor_pos dw ? ;cursor position
maxlen db ? ;maximum input string length
max_page db ? ;number of highest directory page
dir_page db ? ;current directory page
end_flag db ? ;status of text write routines
error_flag db ? ;critical error status
default_cursor dw 0607h ;default cursor shape (color)
addr_6845 dw ? ;CRT Controller base address
search_attr dw 0 ;file search attribute
;
path dw 0 ;pointer to pathname buffer
dta dw 64 ;pointer to Disk Transfer Area
screen_buffer dw offset initialize ;pointer to screen buffer
text_buffer dw offset initialize+1536 ;pointer to filename buffer
;
keyboard_int label dword ;old interrupt 9 vector
old9h dw 2 dup (?)
timer_int label dword ;old interrupt 1Ch vector
old1ch dw 2 dup (?)
bdisk_int label dword ;old interrupt 13h vector
old13h dw 2 dup (?)
bp_int label dword ;old interrupt 28h vector
old28h dw 2 dup (?)
;
old_dta_segment dw ? ;old DTA segment address
old_dta_offset dw ? ;old DTA offset address
old24h_segment dw ? ;old interrupt 24h routine segment
old24h_offset dw ? ;old interrupt 24h routine offset
enable_values db 2Ch,28h,2Dh,29h ;values to enable CGA output
db 2Ah,2Eh,1Eh
errtext db 'No Files Found',0
;
;------------------------------------------------------------------------------
;Execution comes here thru interrupt 9 every time a key is pressed or released.
;------------------------------------------------------------------------------
keyboard proc near
sti ;set interrupt enable flag
push ax ;save AX
in al,60h ;get scan code from keyboard
cmp al,52 ;was the '.' key pressed?
jne kb2 ;no, then exit to normal handler
mov ah,2 ;check shift key status
int 16h
test al,8 ;is the Alt key pressed?
je kb2 ;no, then exit
call kb_reset ;reset keyboard, issue EOI
pop ax ;restore AX
cmp program_status,0 ;XDIR routine already active?
jne kb1 ;yes, then don't set request flag
mov request_flag,1 ;set request flag
kb1: iret ;end interrupt routine
kb2: pop ax ;restore AX
jmp keyboard_int ;goto original keyboard routine
keyboard endp
;
;------------------------------------------------------------------------------
;Interrupt 1Ch handling routine.
;This procedure will now be used to handle int 8 instead of int 1c
;------------------------------------------------------------------------------
timer proc near
pushf ;call original routine
call timer_int
cmp request_flag,0 ;request flag set?
je timer1 ;no, then exit
push es ;save ES and DI
push di
mov es,dos_segment ;get DOS segment in ES
mov di,busy_flag ;address of DOS BUSY_FLAG in DI
cmp byte ptr es:[di],0 ;DOS service currently active?
pop di ;clean up the stack
pop es
jne timer1 ;yes, then we must wait
cmp flag_13h,0 ;BIOS disk service active?
jne timer1 ;yes, then don't interrupt it
test_8259_status:
push AX ;Save altered registers
push DX
mov DX,20h ;Port address of 8259 OCW3
mov AL,03 ;Set the In-Service Reg. read
;bits RR=1 and RIS=1
out DX,AL ;Tell 8259 to send ISR on next read
jmp short get_mask ;This causes a 7 clock delay period
;on the AT to allow time for the 8259
;to setup the ISR status for us
get_mask:
in AL,DX ;Get the ISR
or AL,AL ;Set zero flag if no interrupts are
;being serviced
pop DX ;Restore the altered registers
pop AX
jnz timer1 ;A hard interrupt is in progress
mov request_flag,0 ;reset request flag
call directory ;invoke directory routine
timer1: iret ;done - exit
timer endp
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
;Interrupt 13h handling routine.
;------------------------------------------------------------------------------
bdisk proc far
inc flag_13h ;Set the busy flag
pushf ;Simulate an interrupt call to the
call bdisk_int ;original disk interrupt routine
pushf ;Save returned flags from disk interrupt
dec flag_13h ;Clear the busy flag
popf ;Restore disk I/O status flags
ret 2 ;Far return and discard flags on the stack
bdisk endp
;
;------------------------------------------------------------------------------
;Interrupt 28h handling routine.
;------------------------------------------------------------------------------
backproc proc near
pushf ;call original routine
call bp_int
cmp request_flag,0 ;request flag clear?
je bp1 ;yes, then exit
mov request_flag,0 ;clear request flag
call directo